/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.util;

import com.yanlight.exception.ErrorType;
import com.yanlight.support.http.FailResponse;
import com.yanlight.support.http.Response;
import com.yanlight.support.http.SuccessResponse;

/**
 * @author haolw
 * @time 2016/09/28
 */
public class ResponseUtil {

    /**
     * 返回status:success的response
     *
     * @return
     */
    public static Response success() {
        return new Response();
    }

    /**
     * 返回SuccessResponse
     *
     * @param data
     * @return
     */
    public static Response success(Object data) {
        return new SuccessResponse(data);
    }

    /**
     * 返回FailResponse
     *
     * @param errorCode
     * @param errorMsg
     * @return
     */
    public static Response fail(Integer errorCode, String errorMsg) {
        return new FailResponse(errorCode, errorMsg);
    }

    /**
     * 返回FailResponse
     *
     * @param errorType
     * @return
     */
    public static Response fail(ErrorType errorType) {
        return new FailResponse(errorType.getCode(), errorType.getZhCnMsg());
    }


}
